

/* Procedure that gives back the fractional index for a new value
   in a table. This is a sort of linear interpolation */

//checked by RLdS and MF 2-28-11
using namespace std;

double get_tab_indexes_low(vector<double> table_input, double value_evaluate){
  

  //Input array is monot decreasing
  //Start from the tail, most likely to be there
  
  long index;
  
  //find your location
 // for(index=table_input.size()-1;index>=0;index--){
 //  if(table_input[index] > value_evaluate) break;
 // }
  for(index=0;index<(long)table_input.size();index++){
    if(table_input[index] > value_evaluate) break;
 }
  
  //get the fract index
  double fract_index;
  fract_index=index-(table_input[index]-value_evaluate)/(table_input[index]-table_input[index-1]);
  return fract_index;
  
}
